package dongbai.soft.entity;

import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import dongbai.soft.utils.getUUID;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Map;

/**
 * @author SingDeer
 * @email
 * @date 2023-06-26 14:01:21
 */
@Data
@TableName("product")
@NoArgsConstructor
@AllArgsConstructor
public class ProductEntity implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 货物唯一标识符
     */
    @TableId
    private String pid;
    /**
     * 货物名称
     */
    private String name;
    /**
     * 供货商标识符
     */
    private String sid;
    /**
     * 进价
     */
    private BigDecimal wholesalePrice;
    /**
     * 货物价格
     */
    private BigDecimal price;
    /**
     * 货物A库存数
     */
    private Integer num = 0;

    /**
     * 二级分类标识符
     */
    private String tid;
    /**
     * 警告阈值
     */
    private Integer wnum;
    /**
     * 状态（0表示删除，1表示正常）
     */
    private Boolean status = true;

    public ProductEntity(Map<String, String> maps) {
        this.pid = getUUID.get6UUID();
        this.name = maps.get("name");
        this.sid = maps.get("SID");
        this.price = new BigDecimal(maps.get("price"));
        this.tid = maps.get("TID");
        this.wnum = Integer.parseInt(maps.get("wNum"));
        this.wholesalePrice = new BigDecimal(maps.get("wholesale_price"));
    }

}
